package cn.wolfcode.trip.app.controller;

import cn.wolfcode.trip.base.query.QueryObject;
import cn.wolfcode.trip.base.service.IShoppingTrolleyService;
import cn.wolfcode.trip.base.util.JSONResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/shoppings")
public class ShoppingTrolleyServiceController {

    @Autowired
    private IShoppingTrolleyService shoppingTrolleyService;


    /*
     *清除对应id的购物车内容
     * 资源:/shoppings
     * 动作:DELETE
     * 参数:currentPage=x
     **/
    @DeleteMapping("/byId")
    public Object deleteShoppingById(Long id){
        shoppingTrolleyService.deleteShoppingById(id);
        return new JSONResult();
    }



    /*
     *查询对应id的购物车内容
     * 资源:/shoppings
     * 动作:GET
     * 参数:currentPage=x
     **/
    @GetMapping
    public Object GetShopping(Long[] ids){
        return shoppingTrolleyService.bathchGet(ids);
    }




    /*
     *清除对应id的购物车内容
     * 资源:/shoppings
     * 动作:DELETE
     * 参数:currentPage=x
     **/
    @DeleteMapping
    public Object deleteShopping(Long[] ids){
        if(ids!=null){
            shoppingTrolleyService.bathchDelete(ids);
        }
        return new JSONResult();
    }

}
